
(** array that can be quickly resetted (e.g. zeroed) via reset function. 
Usage: let module Array=Reset_array in ...
*)

type 'a t = ('a array) * (int list ref) * 'a

let make n init : 'a t = Array.make n init, ref [], init

let get ((a,_,_): 'a t) i = a.(i)

let set ((a,l,_): 'a t) i v = a.(i) <- v; l := i :: !l

let reset ((a,l,v1): 'a t) = List.iter (fun i -> a.(i) <- v1) !l; l:= []

